<?php

namespace app\admin\model;

use think\Model;

class Good extends Model
{
    public function getImagesAttr($val)
    {
        $arr = explode(',', $val);
        foreach ($arr as &$v) {
            if ($v) {
                $v = addHost($v);
            }
        }
        return implode(',', $arr);
    }
    public static function list()
    {
        $param = input();
        $list = self::order('sort asc,id desc');
        $status = input('status');
        if (isset($status) && ($status == 0 || $status == 1)) {
            $list->where(['status' => $status]);
        }
        if (!empty($param['good_name'])) {
            $good_name = $param['good_name'];
            $list->where('good_name', 'like', "%$good_name%");
        }
        if (!empty($param['good_type'])) {
            $list->where('good_type', $param['good_type']);
        }
        $list = $list->paginate(10);
        return $list;
    }
}
